<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Jialeo\LaravelSchemaExtend\Schema;

class CreateMapStreetsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('map_national_streets', function (Blueprint $table) {
            $table->id();
            $table->string('wgNumber', 12)->default('')->comment('网规编码');
            $table->string('name', 64)->default('')->comment('街道名称');
            $table->unsignedInteger('status')->default(0)->comment('状态');
            $table->unsignedTinyInteger('grade')->default(0)->comment('网规等级');
            $table->string('province', 32)->default('')->comment('省份');
            $table->string('city', 32)->default('')->comment('城市');
            $table->string('district', 32)->default('')->comment('地区');
            $table->string('address', 128)->default('')->comment('详细地址');
            $table->string('lat', 32)->default('')->comment('经度');
            $table->string('lng', 32)->default('')->comment('纬度');
            $table->json("coords")->nullable()->comment('多边形点位的json');
            $table->unsignedInteger("shopNum")->default(0)->comment('区域内店铺数量');

            $table->unsignedInteger('createdAt')->default(0)->comment('创建时间');
            $table->unsignedInteger('updatedAt')->default(0)->comment('修改时间');
            $table->collation = 'utf8mb4_general_ci';
            $table->comment = '街道规划地区';

            $table->index('wgNumber', 'idx_wgNumber');
            $table->index(['lat', 'lng'], 'idx_middleCoords');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('map_national_streets');
    }
}
